feat: add seconds-based time window support for Thompson Sampling#4
Merged
feat: add seconds-based time window support for Thompson Sampling#4
Conversation
- Add getAllArmsDataWithWindow() method to storage interface and implementation - Add getThompsonScoresWithWindow() method to manager interface and implementation - Implement time-based filtering using seconds for technical precision - Add optimized composite indexes for time window query performance - Add covering index on rl_arm_data for optimal SELECT performance - Maintain backward compatibility with existing getAllArmsData() method - Support filtering arms by activity timestamp (updated column) BREAKING CHANGE: New database indexes require fresh installation or manual index updates Addresses sliding time window functionality for non-stationary content optimization. Enables content marketers to focus recommendations on recently active content. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Aug 11, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements sliding time window functionality for Thompson Sampling to support non-stationary content optimization. Enables content marketers to focus AI recommendations on recently active content while maintaining backward compatibility.
Implementation Details
New Storage Methods
getAllArmsDataWithWindow($experiment_uuid, $time_window_seconds)- Filters arms by activity timestampgetAllArmsData()methodNew Manager Methods
getThompsonScoresWithWindow($experiment_uuid, $time_window_seconds)- Thompson Sampling with time filteringgetThompsonScores()now uses new method internallyDatabase Optimizations
rl_experiment_totals(experiment_uuid, updated)rl_arm_data(experiment_uuid, updated, arm_id, turns, rewards, created)Technical Benefits
Database Schema Changes
BREAKING CHANGE: Requires fresh installation or manual index updates
New indexes replace old separate indexes:
rl_experiment_totals:experiment_uuid+updated→experiment_updated(experiment_uuid, updated)rl_arm_data:experiment_uuid+updated→covering_time_window(experiment_uuid, updated, arm_id, turns, rewards, created)Testing Performed
Use Cases Enabled
Content Types Benefiting:
Content Types Unchanged:
Related Issues & PRs
Resolves: #2
Paired with: dxpr/ai_sorting#7 (UI integration)
Related: dxpr/ai_sorting#5 (UI issue)
Deployment Notes
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com